package com.schedule.aop

import com.yfree.config.YConfig
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.context.event.ApplicationStartedEvent
import org.springframework.context.ApplicationListener
import org.springframework.stereotype.Component
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

@Component
class ApplicationStartAop : ApplicationListener<ApplicationStartedEvent> {
    @Value("\${spring.profiles.active}")
    private lateinit var active: String

    override fun onApplicationEvent(event: ApplicationStartedEvent) {
        YConfig.DEBUG = active != "release"
        YConfig.Request.filterCallBack = { request: HttpServletRequest, response: HttpServletResponse, handle: Any ->
            println("====================== filterCallBack_YFree ======================")
            true
        }
    }
}
